package game.engine.field;

import game.element.actor.Actor;

public class GravityField implements Field {

	public static final int MAXIMUM_DY = 30;

	private static final GravityField SINGLETON = new GravityField();

	public static GravityField singleton() {
		return SINGLETON;
	}

	private GravityField() {
	}

	@Override
	public void doMove(Actor actor) {
		if (actor == null) {
			throw new RuntimeException("Null actor or gamescreen.");
		}
		if (actor.getDy() < MAXIMUM_DY) {
			actor.setDy(actor.getDy() + 1);
		}
	}

	// public void doMove(Actor actor, GameMapLevel gameScreen) {
	// if (actor != null && gameScreen != null) {
	// int highestGround = CollosionDetection.setActorOnGround(actor,
	// gameScreen);
	// if (!actor.isOnGround()) {
	// if (actor.getDy() < 30) {
	// actor.setDy(actor.getDy() + 1);
	// }
	// } else {
	// if (actor.getDy() > 0) {
	// actor.setDy(0);
	// }
	// actor.setY(highestGround - actor.getHeight());
	// }
	// }
	// }

	// @Deprecated
	// public void doMoves(Iterable<Actor> objects, GameMapLevel gameScreen) {
	// for (Actor actor : objects) {
	// doMove(actor);
	// }
	// }
}